package interfacesSIAB;

import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Rectangle;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.BorderFactory;
import java.awt.Color;
import javax.swing.border.TitledBorder;

import administrador.gestion_de_clientes;

import java.awt.Font;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class RetirarCliente extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JPanel jPanel = null;
	private JLabel jLabel = null;
	private JTextField cedula = null;
	private JButton jButton = null;
	private JButton cancelar = null;

	/**
	 * This is the default constructor
	 */
	public RetirarCliente() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(300, 400);
		this.setResizable(false);
		this.setContentPane(getJContentPane());
		this.setTitle("Retirar Cliente");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJPanel(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(49, 54, 135, 26));
			jLabel.setText("       Ingresar Cedula");
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.setBounds(new Rectangle(18, 31, 239, 271));
			jPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.orange), "Cliente", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jPanel.add(jLabel, null);
			jPanel.add(getCedula(), null);
			jPanel.add(getJButton(), null);
			jPanel.add(getCancelar(), null);
		}
		return jPanel;
	}

	/**
	 * This method initializes cedula	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getCedula() {
		if (cedula == null) {
			cedula = new JTextField();
			cedula.setBounds(new Rectangle(51, 111, 131, 20));
			cedula.setColumns(0);
		}
		return cedula;
	}

	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setBounds(new Rectangle(18, 174, 90, 26));
			jButton.setText("Retirar");
			jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
					try {
					if(getCedula().getText().trim().length() > 0 )
					
					{
						gestion_de_clientes eliminar = new gestion_de_clientes();
						eliminar.eliminarCliente(Integer.parseInt(getCedula().getText()));
						getCedula().setText("");
					}
					else{
						
						JOptionPane.showMessageDialog(null,"Por favor Debe de Ingresar la Cedula");
					}
					}
					catch (Exception e1) {
						JOptionPane.showMessageDialog(null,"El siguiente campo no puede contener caracteres"+ e1.getMessage() );
					    e1.printStackTrace();
					}
					
					
				}
			});
		}
		return jButton;
	}

	/**
	 * This method initializes cancelar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCancelar() {
		if (cancelar == null) {
			cancelar = new JButton();
			cancelar.setBounds(new Rectangle(119, 175, 98, 26));
			cancelar.setText("Salir");
			
cancelar.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					
					dispose();
				}
			});
			
		
			
			
			
			
			
		}
		return cancelar;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
